﻿//===========================[ 7 / 8 / 2011 LVI ]=============================
//				Copyright c Vitaly Lyaschenko <SkyChameleon@gmail.com>
// 								Header file
// Purpose: базовый класс от которого необходимо наследовать 
//=============================================================================
#pragma once

#include "cTimer.h"
#include "cwLogger.h"
#include "Singleton.h"
#include "cFileManager.h"
#include "cSoundManager.h"
#include "IAbstractApp.h"
#include "cRenderDevice.h"
#include "cLuaScript.h"
#include "cInput.h"
#include "cConfig.h"
#include <windows.h>


class Kernel : public cSingleton<Kernel>
{
public:
	Kernel(void);
	~Kernel(void);

	bool Create();
	int ExecLoop();  
	void QuitLoop();
	void Destroy();

	cTimer*        getTimer()  const { return m_Timer;	}
	cRenderDevice* getRender() const { return m_Render; }
	cLuaScript*    getScript() const { return m_Script; }
	cMouse*        getMous()   const { return m_Mouse;  }


	void setAbstractApp( IAbstractApp *pApp ) { m_AbstractApp = pApp; }
	void setWindowSetting( int width, int height, bool fullScreen );
	void setWindowTitle( const char *title );

	HWND getHWND() const { return m_hWnd; }

private:
	bool CreateRenderWindow();
	void AdjustDisplaySettings();
	void CloseRenderWindow();


	static	LRESULT CALLBACK StaticWndProc( HWND hWindow, UINT Msg, WPARAM wParam, LPARAM lParam );
	LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);

	cParserCfg *m_ParserCfg;
	DisplayCfg *m_DisplayCfg;
	cwLogger   *m_Logger;
	cTimer     *m_Timer;
	cLuaScript *m_Script;
	cMouse     *m_Mouse;

	cFileManager  *m_FileManager;
	cSoundManager *m_soundManager;
	IAbstractApp  *m_AbstractApp;
	cRenderDevice *m_Render;

	HWND m_hWnd;
	//HDC m_hDc;
	HINSTANCE m_hInstance;
};